<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >
                <p:growl />
                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel header="Manage Discount Scheme Payment Method" >
                    <h:panelGrid id ="gpVeda" columns="2" >

                        <p:panel>
                            <h:panelGrid id="gpSelect" columns="2"  >
                                <h:outputText  value="Discount Scheme" />
                                <p:selectOneMenu  value="#{paymentSchemeController.membershipScheme}" >
                                    <f:selectItem itemLabel="Select Member Ship Scheme"/>
                                    <f:selectItems value="#{membershipSchemeController.items}"/>
                                    <f:ajax event="change" render="@all" execute="@this" listener="#{paymentSchemeController.createAllowedPaymentMethods()}" />                                        
                                </p:selectOneMenu>
                                <h:outputText  value="Allowed Methords" />
                                <h:panelGrid id="gpSelectText" >
                                    <h:selectOneListbox  id="lstSelect"   size="10" value="#{paymentSchemeController.currentAllowedPaymentMethod}" style="min-width: 223px">
                                        <f:selectItems  value="#{paymentSchemeController.allowedPaymentMethods}" 
                                                        var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.paymentMethod}" ></f:selectItems>
                                        <f:ajax render="gpDetail" execute="lstSelect" >
                                        </f:ajax>
                                    </h:selectOneListbox>
                                </h:panelGrid>

                            </h:panelGrid  >
                            <h:panelGrid id="gpSelectButtons" columns="3"  >

                                <p:commandButton ajax="false" id="btnAdd" value="Add" 
                                                 action="#{paymentSchemeController.prepareAdd()}" 
                                                 styleClass="buttons" />                                       


                                <p:commandButton ajax="false" id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                return false;" action="#{paymentSchemeController.delete()}"  value="Delete"  >
                                </p:commandButton>

                                <p:commandButton ajax="false" value="Clear"
                                                 action="#{paymentSchemeController.recreateModel}"/>

                            </h:panelGrid>
                        </p:panel>

                        <p:panel>
                            <h:panelGrid id="gpDetail" columns="1">
                                <h:panelGrid id="gpDetailText" columns="2">                                  
                                    <h:outputText value="Payment Method" ></h:outputText>
                                    <p:selectOneMenu value="#{paymentSchemeController.currentAllowedPaymentMethod.paymentMethod}" >
                                        <f:selectItem itemLabel="Select Payment Method"/>
                                        <f:selectItems value="#{enumController.paymentMethods}"/>
                                    </p:selectOneMenu>

                                    <h:commandButton id="btnSave"  value="Add" action="#{paymentSchemeController.saveSelectedAllowedPaymentMethod()}" styleClass="buttons">                                        
                                    </h:commandButton>
                                </h:panelGrid>

                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
